package wang.app.demo.handler;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author dj.wang
 * @Date 2020/6/22 23:31
 * @Version V1.0
 */
@RestControllerAdvice
public class GlobeExceptionHandler
{
    @ExceptionHandler(UnauthorizedException.class)
    @ResponseBody
    public String handleException(HttpServletRequest request, UnauthorizedException ex)
    {
        return "Unauthorized";
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String handleException(HttpServletRequest request, Exception ex)
    {
        return "ExceptionHandler";
    }
}
